/*! \file jbfile.h
	\author HiddenSeeker
	Describes a java bytecoded file, that can write itself to file
 */
#include <vector>
#include <string>
#pragma once
class ConstantTable;


void reversebytes(char * dest, char * src, unsigned int size);
unsigned short reverse(unsigned short c);
short reverse(short c);
int   reverse(int c);
float reverse(float c);

class JBFile
{
private:
	std::vector<unsigned char> m_bytes;
	std::string                m_filename;
public:
	JBFile(const std::string & filename);

	inline void write(unsigned char c)
	{
		m_bytes.push_back(c);
	}

	void write(unsigned short size);
	void write(short size);
	void write(int size);
	void write(float size);
	void writeAt(int what,int offset);
	void writeAt(short what,int offset);
	void reserveBytes(unsigned int size);
	void print();
	void save();

	inline int getOffset()  { return m_bytes.size();}
	~JBFile();
};